package threadLock.threadBasics.interrupt;

/**
 * 线程的isInterrupted和静态Thread.isInterrupted
 * 思考 为什么第二三四是 false false true
 * interrupted 方法获取的是当前线程的中断标记  无论是那个线程调用 都是调用的当前线程的中断标记 可以点开源码查看
 */
public class InterruptedThread {
    public static void main(String[] args) throws InterruptedException{
        Thread threadOne = new Thread(() -> {
            for (;;){}
        });
        threadOne.start();
        threadOne.interrupt();
        System.out.println("isInterrupted: "+ threadOne.isInterrupted());
        System.out.println("isInterrupted: "+ threadOne.interrupted());
        System.out.println("isInterrupted: "+ Thread.interrupted());
        System.out.println("isInterrupted: "+ threadOne.isInterrupted());
    }
}
